package main

import "fmt"

type calculator struct {
	number1 float64
	number2 float64
}

func newCalculator(number1 float64, number2 float64) *calculator {
	return &calculator{number1: number1, number2: number2}
}

func (c *calculator) getRes(operator byte) float64 {
	var result float64 = 0
	switch operator {
	case '+':
		result = c.number1 + c.number2
	case '-':
		result = c.number1 - c.number2
	case '*':
		result = c.number1 * c.number2
	case '/':
		result = c.number1 / c.number2
	default:
		fmt.Println("输入有误")
	}
	return result
}
func main() {
	cal := newCalculator(5.5, 4.5)
	fmt.Println(cal.getRes('+'))
	fmt.Println(cal.getRes('-'))
	fmt.Println(cal.getRes('*'))
	fmt.Println(cal.getRes('/'))
}

//面向对象
